#为什么要继承object? https://www.runoob.com/note/28629
#python3默认继承
#self参数是this,other参数并不是固定的,在调用p1.computed_gap()的时候,传入了p2,那么other就是p2对象的地址
import math
class Point():
    def __init__(self,x=0,y=0,name="初始化的") -> None:
        self.x=x
        self.y=y
        self.name=name
    def move_to(self,x,y):
        self.x=x
        self.y=y
    def move_add(self,add_x,add_y):
        self.x+=add_x
        self.y+=add_y
    def computed_gap(self,other):
        gap_x=self.x-other.x
        gap_y=self.y-other.y
        gap_s= math.sqrt(gap_x**2+gap_y**2)
        print(f"other:{other.name}")
        return gap_s
def main():
    p1 = Point(1,2,"p1")
    p2 = Point(0,0,"p2")
    p2.move_add(4, 6)
    print(p1.computed_gap(p2))


if __name__ == '__main__':
    main()